package com.jarveis.dbs.core.filter;

import org.apache.log4j.Logger;

import com.jarveis.frame.util.Param;

/**
 * @desc 系统日志过滤器
 * @author liuguojun
 * @create 2015-07-27
 */
public class LoggerFilter implements Filter {

	private Logger logger = Logger.getLogger(LoggerFilter.class);

	public static final String IGNORE = "@__ignore";

	public int init() {

		return 0;
	}

	public int filter(Param param) {

		try {
			// 获取日志忽略标识
			boolean ignore = param.getHead().getBoolean(IGNORE);
			if (!ignore) {
				logger.info(param.toString());
			} else {
				param.getHead().removeProperty(IGNORE);
			}
			
		} catch (Exception ex) {
			logger.error(ex.getMessage(), ex);
		}

		return 0;
	}

	public int destory() {

		return 0;
	}
}
